#Los parametros en orden q cambian en cada lvl:
#[ 
	#~ ball_speed_x, 
	#~ ball_speed_y, 
	#~ p1.paddle_height, 
	#~ p2.paddle_height, 
	#~ p1.paddle_speed_y, 
	#~ p2.paddle_speed_y
#~ ]
# Se le suma esa cantidad al parametro original
# El primero son los valores default para resetear

# Esto es moooy especifico... Tengo q tomar explicitamente los players y la ball
# en el constructor

levels = [[3.0, 3.0, 213, 213, 2.5, 2.5],
		  [0.5, 0.5,  13, -13, 0.0, 0.0],
		  [0.0, 0.0,   0,   0, 0.2, -0.1],
		  [0.2, 0.2,   0, -20, 0.2, -0.1],
		  [0.2, 0.2,   0, -20, 0.2, -0.1],
		  [0.2, 0.2,   0, -20, 0.2, -0.1],
		  [0.2, 0.2,   0, -20, 0.2, -0.1],
		  [0.2, 0.2,   0, -20, 0.2, -0.1]]

import defs
class Level:
	def __init__(self):
		self.curr_lvl = 0
	
	def __init__(self, player1, player2, ball):
		self.curr_lvl = 0
		self.player1 = player1
		self.player2 = player2
		self.ball    = ball
	
	def reset(self):
		self.curr_lvl = 1
		self.set_lvl(0)
		
	def next_lvl(self):

		self.curr_lvl += 1
		if self.curr_lvl > len(levels):
			self.curr_lvl = len(levels)
		self.set_lvl(self.curr_lvl)
		
	def prev_lvl(self):
		self.curr_lvl -= 1
		self.set_lvl(self.curr_lvl)

	def set_lvl(self,lvl):
		if lvl < len(levels):			
			self.ball.increaseSpeed(levels[lvl][0], levels[lvl][1])
			
			self.player1.height += levels[lvl][2]
			self.player2.height += levels[lvl][3]
			
			if defs.ai:
				self.player1.ai_speed += levels[lvl][4]
			else:
				self.player1.speed_rate += levels[lvl][4]
			self.player2.speed_rate += levels[lvl][5]
			
			print "Level", str(self.curr_lvl)
